<template>
  <view class="container">
    <view class="header">
      <view class="header_box">
        <view class="header_photo" @click="getPersonal">
          <image :src="isLogin? userInfo.avatar : 'http://qichong-1256206693-1256206693.cos.ap-nanjing.myqcloud.com/upload/20210617/a1b0aedabc466612a506a75eda513e72.png'" mode="aspectFill">
          </image>
          <block v-if="isLogin">
            <image src="/static/images/mine/nan.png" mode="widthFix" class="minImage" v-if="userInfo.sex == '0'">
            </image>
            <image src="/static/images/mine/nv.png" mode="widthFix" class="minImage" v-if="userInfo.sex == '1'"></image>
          </block>
        </view>
        <view class="hearder_text" v-if="isLogin">
          <view class="hearder_text_num">{{userInfo.name}}</view>
          <view class="hearder_text_vip" v-if="getUserVipItem && getUserVipItem.length !== 0">
            <!-- 有 -->
            <view class="hearder_text_vip_box1">
              <view class="hearder_text_vip_box_v1">
                v
              </view>
            </view>
            <text class="hearder_text_vip_right1">
              会员剩余次数<text
                style="margin: 0 10rpx;font-weight: 900;color: #fc6538;">{{getUserVipItem.residueNumber}}</text>次
            </text>
          </view>
          <view class="hearder_text_vip" v-else>
            <!-- 无 -->
            <view class="hearder_text_vip_box">
              <view class="hearder_text_vip_box_v">
                v
              </view>
            </view>
            <text class="hearder_text_vip_right">
              未开通会员
            </text>
          </view>
        </view>
        <view class="hearder_text" v-else>
          <navigator hover-class="none" url="../../login/login">未登录</navigator>
          <text class="hearder_text_title">欢迎来到奇宠日记 ~</text>
        </view>
      </view>
      <view class="header_userInfo" v-if="isLogin" @click="navTo('/subpkg/userInfo/userInfo?id=' + userInfo.id)">
        <h1>个人主页</h1>
        <van-icon name="arrow" />
      </view>
    </view>

    <!-- 粉丝以及关注列表 -->
    <view class="community" v-if="isLogin">
      <view class="community_box" @click="navTo('/subpkg/attentionlist/attentionlist')">
        <h1>{{userInfo.followers}}</h1>
        <text>关注</text>
      </view>
      <view class="community_box" @click="navTo('/subpkg/fanslist/fanslist')">
        <h1>{{userInfo.followeds}}</h1>
        <text>粉丝</text>
      </view>
      <view class="community_box" @click="navTo('/subpkg/userInfo/userInfo?id=' + userInfo.id)">
        <h1>{{userInfo.posts}}</h1>
        <text>动态</text>
      </view>
      <view class="community_box" @click="navTo('/subpkg/userInfo/userInfo?id=' + userInfo.id)">
        <h1>{{userInfo.articles}}</h1>
        <text>文章</text>
      </view>
    </view>


    <view class="CardVip">
      <image src="http://qichong-1256206693-1256206693.cos.ap-nanjing.myqcloud.com/upload/20210617/9c4ef1e95288aa0190bcd18032b8204e.png" mode=""></image>
      <navigator url="/subpkg/member/member" class="CardVip_text">
        {{getUserVipItem.length !== 0? '立即前往':'开通会员'}}
      </navigator>
      <view class="CardVip_img" v-if="!isLogin">
        <image src="http://qichong-1256206693-1256206693.cos.ap-nanjing.myqcloud.com/upload/20210617/2df27b6f306711c43fd4bd632c0360b3.png" mode="aspectFill"></image>
      </view>
    </view>


    <!-- 我的宠物 -->
    <view class="footer">
      <view class="footer_title">
        我的宠物
        <navigator hover-class="none" url="/subpkg/more/more">更多宠物</navigator>
      </view>

      <!-- 宠物 -->
      <scroll-view class="my_pet" scroll-x="true">

        <view class="my_pet_list" @click="navTo('/subpkg/ldentity/ldentity?id=' + item.id)"
          v-if="getRecordItem.length !== 0" v-for="(item,i) in getRecordItem" :key="i">
          <view class="my_pet_list_text">
            <view class="my_pet_list_img">
              <image v-if="item.previewImage" :src="item.previewImage" mode="aspectFill"></image>
              <image v-else src="http://qichong-1256206693-1256206693.cos.ap-nanjing.myqcloud.com/upload/20210617/a1b0aedabc466612a506a75eda513e72.png" mode="aspectFill"></image>
            </view>
            <view class="my_pet_list_title">
              <h1>{{item.productName}}</h1>
              <text>{{item.ageStr}}</text>
            </view>
          </view>
        </view>

        <view class="my_pet_item" @click="navTo('/subpkg/newrecord/newrecord')">
          <view class="my_pet_item_text">
            <image src="/static/images/mine/add.png" mode="aspectFill"></image>
            <text>添加新的小伙伴</text>
          </view>
        </view>
      </scroll-view>
    </view>

    <view class="remind" v-if="isLogin" @click="healthClick">
      <view class="remind_box" @click="geteverydayShow">
        <image src="/static/images/mine/richangjilu.png" mode="aspectFill"></image>
        <text>日常记录</text>
      </view>
      <view class="remind_box" @click="gethealthShow">
        <image src="/static/images/mine/jiangkang.png" mode="aspectFill"></image>
        <text>健康记录</text>
      </view>
      <view class="remind_box" @click="navTo('/subpkg/health/health')">
        <image src="/static/images/mine/shenghuo.png" mode="aspectFill"></image>
        <text>生活日记</text>
      </view>
      <view class="remind_box" @click="navTo('/subpkg/remind/remind')">
        <view v-if="userInfo.reminderCount" class="quantity" style="color: #fff;font-weight: 500;">
          {{userInfo.reminderCount}} </view>
        <image src="/static/images/mine/jilutixing.png" mode="aspectFill"></image>
        <text>记录提醒</text>
      </view>
    </view>

    <view class="footer footer1">
      <view class="footer_title footer_title1">
        功能与服务
      </view>
      <view class="footer_body">
        <view class="footer_body_box" @click="navTo('/subpkg/orderList/orderList')">
          <image src="/static/images/mine/wodedingdan.png" mode="aspectFill"></image>
          <text>我的订单</text>
        </view>
        <view class="footer_body_box" @click="navTo('/subpkg/consumption/consumption')">
          <image src="/static/images/mine/xiaofeijilu.png" mode="aspectFill"></image>
          <text>消费记录</text>
        </view>
        <!--   <view class="footer_body_box" @click="navTo('/pages/tabbar/queue/queue')" v-if="isLogin">
          <image src="/static/images/mine/queue.png" mode="aspectFill"></image>
          <text>排队叫号</text>
        </view> -->
        <view class="footer_body_box" @click="navTo('/subpkg/newest/newest')" v-if="isLogin && !userInfo.isUser">
          <image src="/static/images/mine/queue.png" mode="aspectFill"></image>
          <text>店员排队</text>
        </view>
        <view class="footer_body_box" @click="navTo('/subpkg/cancel/cancel')" v-if="isLogin && !userInfo.isUser">
          <image src="/static/images/mine/dingdanhexiao.png" mode="aspectFill"></image>
          <text>订单核销</text>
        </view>
        <!-- <view class="footer_body_box" @click="navTo('/subpkg/coupons/coupons')">
          <image src="/static/images/mine/youhuijuan.png" mode="aspectFill"></image>
          <text>优惠卷</text>
        </view> -->
        <view class="footer_body_box" @click="navTo('/subpkg/newshoprecord/newshoprecord')"
          v-if="isLogin && !userInfo.isUser">
          <image src="/static/images/mine/addpet.png" mode="aspectFill"></image>
          <text>店员建档</text>
        </view>
		<view class="footer_body_box" @click="navTo('/subpkg/analysis/ticket')"
			v-if="isLogin && !userInfo.isUser">
		  <image src="/static/images/mine/analysis.png" mode="aspectFill"></image>
		  <text>数据统计</text>
		</view>
        <view class="footer_body_box" @click="navTo('/subpkg/setting/setting')">
          <image src="/static/images/mine/shezhi.png" mode="aspectFill"></image>
          <text>设置</text>
        </view>
      </view>
    </view>

    <!-- 日常弹框 -->
    <van-popup :show="everydayShow" round position="bottom" custom-style="height: 45%" @close="oneverydayClose">
      <view class="everyday">
        <view class="everyday_box">
          <block v-for="(item,i) in labelList" :key="i">
            <view class="everyday_box_Item"
              @click="navTo('/subpkg/addrecordList/addrecordList?name=' + item.tagName+ '&id=' + item.id)">
              <image :src="item.previewImage" mode="aspectFill"></image>
              <text>{{item.tagName}}</text>
            </view>
          </block>
        </view>
        <view class="everyday_no" @click="oneverydayClose">
          <image src="/static/everyday/no.png" mode="aspectFill"></image>
        </view>
      </view>
    </van-popup>

    <!-- 日常弹框 -->
    <van-popup :show="healthShow" round position="bottom" custom-style="height: 45%" @close="onhealthClose">
      <view class="everyday">
        <view class="everyday_box">
          <block v-for="(item,i) in labelList" :key="i">
            <view class="everyday_box_Item"
              @click="navTo('/subpkg/addrecordList/addrecordList?name=' + item.tagName + '&id=' + item.id)">
              <image :src="item.previewImage" mode="aspectFill"></image>
              <text>{{item.tagName}}</text>
            </view>
          </block>
        </view>
        <view class="everyday_no" @click="onhealthClose">
          <image src="/static/everyday/no.png" mode="aspectFill"></image>
        </view>
      </view>
    </van-popup>
  </view>
</template>
<script>
  import {
    mapGetters,
    mapActions,
    mapState,
    mapMutations
  } from 'vuex'
  import {
    getUserVip,
    RecordUserId
  } from '@/api/user.js'
  import {
    getLabel
  } from '@/api/remind.js'
  export default {
    data() {
      return {
        // getUserVipItem: [],
        // getRecordItem: []
        flag: true,
        // 日常弹框
        everydayShow: false,
        // 健康
        healthShow: false,
        labelList: []
      }
    },
    computed: {
      ...mapGetters('m_user', ['currentLocation', 'currentStoreId', 'isLogin', 'userInfo']),
      ...mapGetters('m_pet', ['getRecordItem', 'getUserVipItem'])
    },
    onShow() {

    },
    methods: {
      navTo(url) {
        uni.navigateTo({
          url: url
        })
      },
      getPersonal() {
        if (this.isLogin) {
          uni.navigateTo({
            url: '/subpkg/personal/personal'
          })
        }
      },
      geteverydayShow() {
        this.everydayShow = true
        getLabel(0).then(res => {
          // console.log(res)
          this.labelList = res.data
        })
      },
      gethealthShow() {
        this.healthShow = true
        getLabel(1).then(res => {
          // console.log(res)
          this.labelList = res.data
        })
      },
      oneverydayClose() {
        this.everydayShow = false
      },
      onhealthClose() {
        this.healthShow = false
      },
      healthClick(e) {
        if (this.getRecordItem.length != 0) {
          return
        } else {
          this.$util.Tips({
            title: '请去新建宠物档案哦'
          });
          e.stopPropagation()
        }
      }
    }
  }
</script>
<style lang='scss'>
  /deep/.uni-scroll-view ::-webkit-scrollbar {
    /* 隐藏滚动条，但依旧具备可以滚动的功能 */
    display: none;
    width: 0;
    height: 0;
    color: transparent;
    background: transparent;
  }

  /deep/::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
    color: transparent;
    background: transparent;
  }

  page {
    background-color: #fff;

    .container {
      padding: 0 24rpx 20rpx;


      .header {
        display: flex;
        align-items: center;
        justify-content: space-between;

        .header_box {
          display: flex;
          align-items: center;
          /* justify-content: space-between; */
          height: 236rpx;
          /* background-color: #1989FA; */

          .header_photo {
            width: 142rpx;
            height: 142rpx;
            margin-right: 25rpx;
            position: relative;

            image {
              width: 100%;
              height: 100%;
              border-radius: 50%;
            }

            .minImage {
              position: absolute;
              right: 6rpx;
              bottom: 0;
              width: 40rpx;
              height: 40rpx;
              border: 1px solid #fff;
              border-radius: 50%;
            }

          }

          .hearder_text {
            margin-top: 20rpx;

            navigator {
              font-size: 40rpx;
              font-weight: bold;
            }

            .hearder_text_num {
              padding-left: 5rpx;
              padding-bottom: 7rpx;
            }

            .hearder_text_title {
              font-size: 26rpx;
              color: rgba(200, 200, 200, 1);
              margin-top: 5px;
            }

            .hearder_text_vip {
              position: relative;
              display: flex;
              align-items: center;
              /* width: 220rpx; */
              height: 44rpx;
              text-align: center;
              font-size: 22rpx;
              margin-top: 10rpx;

              .hearder_text_vip_box {
                position: relative;
                z-index: 10;
                width: 60rpx;
                height: 60rpx;
                box-sizing: border-box;
                border: 5rpx solid #fff;
                /* background-color: #07C160; */
                border-radius: 50%;
                display: flex;
                justify-content: center;
                align-items: center;
                overflow: hidden;

                .hearder_text_vip_box_v {
                  width: 100%;
                  height: 100%;
                  border: 6rpx solid rgba(237, 237, 237, 1);
                  background-color: rgba(212, 212, 212, 1);
                  line-height: 35rpx;
                  font-size: 30rpx;
                  border-radius: 50%;
                  color: #fff;
                  box-sizing: border-box;
                }
              }

              .hearder_text_vip_right {
                position: relative;
                left: -25rpx;
                z-index: 1;
                display: inline-block;
                /* width: 160rpx; */
                /* height: 39rpx; */
                background-color: rgba(237, 237, 237, 1);
                border-top-left-radius: 25rpx;
                border-top-right-radius: 5rpx;
                border-bottom-right-radius: 25rpx;
                border-bottom-left-radius: 25rpx;
                padding: 4px 23rpx 9rpx 45rpx;
                color: rgba(61, 61, 61, 0.8);
                font-size: 20rpx;
              }

              .hearder_text_vip_box1 {
                position: relative;
                z-index: 10;
                width: 60rpx;
                height: 60rpx;
                box-sizing: border-box;
                border: 5rpx solid #fff;
                /* background-color: #07C160; */
                border-radius: 50%;
                display: flex;
                justify-content: center;
                align-items: center;
                overflow: hidden;

                .hearder_text_vip_box_v1 {
                  width: 100%;
                  height: 100%;
                  border: 6rpx solid #fdd338;
                  background: linear-gradient(90deg, rgba(255, 87, 51, 1) 0%, rgba(255, 141, 26, 1) 100%);
                  line-height: 36rpx;
                  font-size: 30rpx;
                  border-radius: 50%;
                  color: #fff;
                  box-sizing: border-box;
                  font-weight: 500;
                }
              }

              .hearder_text_vip_right1 {
                position: relative;
                left: -25rpx;
                z-index: 1;
                display: inline-block;
                /* width: 160rpx; */
                /* height: 39rpx; */
                background: linear-gradient(180deg, rgba(255, 227, 128, 1) 0%, rgba(253, 211, 56, 1) 100%);
                border-top-left-radius: 25rpx;
                border-top-right-radius: 5rpx;
                border-bottom-right-radius: 25rpx;
                border-bottom-left-radius: 25rpx;
                padding: 4px 23rpx 9rpx 45rpx;
                color: rgba(61, 61, 61, 0.8);
                font-size: 20rpx;
              }

            }
          }
        }

        .header_userInfo {
          display: flex;
          justify-content: flex-end;
          align-items: center;
          font-size: 28rpx;
          color: rgba(61, 61, 61, 0.6);

          h1 {
            margin-right: 20rpx;
          }
        }
      }

      .community {
        padding: 15rpx 0 55rpx 0;
        display: flex;
        justify-content: space-around;
        align-items: center;

        .community_box {
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;

          h1 {
            font-weight: bold;
            color: rgba(61, 61, 61, 1);
            font-size: 44rpx;
          }

          text {
            margin-top: 5rpx;
            color: rgba(61, 61, 61, 0.6);
            font-size: 28rpx;
          }
        }
      }

      .CardVip {
        width: 702rpx;
        height: 128rpx;
        position: relative;

        image {
          width: 100%;
          height: 100%;
        }

        .CardVip_text {
          position: absolute;
          right: 30rpx;
          top: 40rpx;
          width: 175rpx;
          text-align: center;
          line-height: 52rpx;
          font-size: 30rpx;
          font-weight: bold;
          height: 52rpx;
          background-color: rgba(238, 223, 192, 1);
          border-radius: 26.5rpx;
        }

        .CardVip_img {
          position: absolute;
          right: 35rpx;
          top: -168rpx;
          width: 158rpx;
          height: 168rpx;
        }
      }

      .footer1 {
        padding: 0 !important;
      }

      .footer_title1 {
        padding: 0 24rpx;
      }

      .footer {
        /* height: 200px; */
        background-color: #fff;
        border-radius: 20rpx;
        margin-top: 28rpx;
        padding: 0 24rpx 10rpx;
        box-shadow: 0px 0px 20rpx 3rpx rgba(0, 0, 0, 0.04);

        .border {
          border-bottom: 1px solid #F5F5F7;
        }

        .footer_title {
          display: flex;
          justify-content: space-between;
          font-size: 36rpx;
          height: 128rpx;
          line-height: 128rpx;
          font-weight: bold;

          navigator {
            font-size: 30rpx;
            color: rgba(61, 61, 61, 0.7);
            font-weight: normal;
          }
        }

        .my_pet {
          padding-bottom: 35rpx;
          height: 171rpx;
          display: flex;
          align-items: center;
          width: 100%;
          overflow: hidden;
          white-space: nowrap;

          .my_pet_item {
            display: inline-block;
            width: 317rpx;
            height: 160rpx;
            border-radius: 15rpx;
            border: 1px dashed rgba(61, 61, 61, 0.15);
            margin-right: 15rpx;
            box-sizing: border-box;
            vertical-align: top;

            .my_pet_item_text {
              display: flex;
              justify-content: center;
              align-items: center;
              height: 100%;


              image {
                width: 48rpx;
                height: 48rpx;
              }

              text {
                font-size: 26rpx;
                margin-left: 12rpx;
                color: rgba(61, 61, 61, 0.6);
              }
            }
          }

          .my_pet_list {
            display: inline-block;
            width: 317rpx;
            height: 160rpx;
            border-radius: 15rpx;
            border: 2rpx solid rgba(61, 61, 61, 0.1);
            margin-right: 20rpx;
            box-sizing: border-box;

            .my_pet_list_text {
              display: flex;
              justify-content: center;
              align-items: center;
              height: 100%;

              .my_pet_list_img {
                width: 94rpx;
                height: 94rpx;
                border-radius: 50%;
                margin-right: 17rpx;
                overflow: hidden;

                image {
                  width: 100%;
                  height: 100%;
                }
              }

              .my_pet_list_title {

                h1 {
                  font-size: 30rpx;
                  width: 147rpx;
                  overflow: hidden;
                  text-overflow: ellipsis;
                  white-space: nowrap;
                }

                text {
                  font-size: 22rpx;
                  color: rgba(61, 61, 61, 0.6);
                }
              }
            }
          }
        }

        .footer_body {
          width: 100%;
          display: flex;
          flex-wrap: wrap;

          .footer_body_box {
            width: 25%;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            padding: 10rpx 0 45rpx;

            image {
              width: 48rpx;
              height: 48rpx;
            }

            text {
              color: rgba(61, 61, 61, 1);
              font-size: 24rpx;
              margin-top: 15rpx;
              font-weight: 500;
            }
          }
        }
      }

      .remind {
        height: 182rpx;
        background-color: rgba(255, 255, 255, 1);
        box-shadow: 0px 0px 20rpx 3rpx rgba(0, 0, 0, 0.04);
        border-radius: 20rpx;
        margin-top: 28rpx;
        display: flex;
        justify-content: space-around;
        align-items: center;

        .remind_box {
          position: relative;
          display: flex;
          flex-direction: column;
          justify-content: center;
          align-items: center;

          .quantity {
            position: absolute;
            top: -10rpx;
            right: 0;
            width: 30rpx;
            height: 30rpx;
            background-color: rgba(255, 87, 51, 1);
            border-radius: 15rpx;
            text-align: center;
            line-height: 30rpx;
            font-size: 20rpx;
            color: rgba(61, 61, 61, 1);
          }

          image {
            width: 48rpx;
            height: 48rpx;
          }

          text {
            color: rgba(61, 61, 61, 1);
            font-size: 24rpx;
            margin-top: 15rpx;
            font-weight: 500;
          }
        }
      }
    }
  }

  .everyday {
    position: relative;
    width: 100%;
    height: 100%;

    .everyday_box {
      padding-top: 30rpx;
      height: 80%;
      display: flex;
      flex-wrap: wrap;
      align-content: space-around;

      .everyday_box_Item {
        width: 25%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;

        image {
          width: 98rpx;
          height: 98rpx;
        }

        text {
          margin-top: 20rpx;
        }
      }
    }

    .everyday_no {
      position: absolute;
      left: 50%;
      bottom: 20rpx;
      transform: translateX(-50%);
      width: 58rpx;
      height: 58rpx;

      image {
        width: 100%;
        height: 100%;
      }
    }
  }
</style>
